<template>
    <div class="app-container" v-loading.fullscreen.lock="fullLoading">
        <div class="sign">
            <el-collapse v-model="activeNames" style="margin-left: 10px;">
                <el-collapse-item class="sign-item" title="申请要求:综合素质优秀。学年综合测评班级排名前30%；学习成绩优良，无不及格、补考、重修科目；体能成绩合格等" name="1">
                    <div class="sign-item-content">
                        （一）自觉学习马克思列宁主义、毛泽东思想、邓小平理论、“三个代表”重要思想、科学发展观、习近平新时代中国特色社会主义思想，深刻领悟“两个确立”的决定性意义，增强“四个意识”、坚定“四个自信”、做到“两个维护”，树立共产主义远大理想和中国特色社会主义共同理想。
                    </div>
                    <div>（二）热爱和拥护中国共产党，牢固树立爱国主义思想，积极培育和践行社会主义核心价值观，具有敢于担当、不懈奋斗、自强不息的精神。</div>
                    <div>（三）遵守宪法、法律、法规，遵守公民道德规范，遵守学校管理制度，具有良好的道德品质和行为习惯，无违法违纪记录。s</div>
                    <div>（四）综合素质优秀。学年综合测评班级排名前30%；学习成绩优良，无不及格、补考、重修科目；体能成绩合格。</div>
                    <div>（五）积极参与体育锻炼，身心健康、人格健全，具有乐观向上的人生态度，心理素质良好、人际关系和谐。</div>
                    <div>（六）积极参与公益劳动和社会实践等社会主义精神文明建设活动。</div>
                </el-collapse-item>
                <el-collapse-item title="学业之星:学业成绩名列前茅。学年平均学分绩在专业排名前5%；获得校级及以上先进个人项目表彰" name="2">
                    <div>学业成绩名列前茅。学年平均学分绩在专业排名前5%；获得校级及以上先进个人项目表彰；</div>
                    <div>专业领域成果突出。在与专业相关的知识竞赛、技能竞赛中获奖。优先推荐发表过专业论文者。</div>
                </el-collapse-item>
                <el-collapse-item title="技能之星:在省部级及以上举办的技能类、创新创业类比赛中获得三等奖及以上等" name="3">
                    <div>
                        技能或创新创业比赛成绩优异。积极参加技能训练、技能比赛或创新创业类比赛，在省部级及以上举办的技能类、创新创业类比赛中获得三等奖及以上，或在市厅级举办的技能类、创新创业类比赛中获得二等奖及以上，或在校级组织的技能类、创新创业类比赛中获得一等奖及以上；
                    </div>
                    <div>专业技能成绩优良。在本专业技能考核中成绩突出，学年平均学分绩在专业排名前30%；</div>
                    <div>专业技能突出。取得与专业相关的资格、资质证书、专利（排名前五）或者在专业技能某个方面特别突出者优先考虑。</div>
                </el-collapse-item>
                <el-collapse-item title="励志之星:在评选学年中被认定为家庭经济困难学生，自立自强，热爱生活，吃苦耐劳，勇于拼搏，乐观向上，有突出的励志事迹，能够激励他人、影响他人，在同学中认可度高；" name="4">
                    <div>在评选学年中被认定为家庭经济困难学生，自立自强，热爱生活，吃苦耐劳，勇于拼搏，乐观向上，有突出的励志事迹，能够激励他人、影响他人，在同学中认可度高；</div>
                    <div>在专业学习、勤工俭学、社会实践、科技创新、励志感恩、创新创业、公益服务等方面取得突出成绩；</div>
                    <div>学业成绩优良，学年平均学分绩在专业排名前30%，获得校级及以上先进个人项目表彰。</div>
                </el-collapse-item>
                <el-collapse-item title="才艺之星:才艺成绩突出。在校内外各类文体赛事中（如体育、美术、音乐、舞蹈、戏剧、摄影摄像、写作、演讲、辩论等）成绩突出。" name="5">
                    <div>才艺成绩突出。在校内外各类文体赛事中（如体育、美术、音乐、舞蹈、戏剧、摄影摄像、写作、演讲、辩论等）成绩突出。</div>
                    <div>学业成绩优良。学年平均学分绩在专业排名前30%。</div>
                </el-collapse-item>
                <el-collapse-item title=" 服务之星:积极主动为师生服务。在团委、学生会、易班、社团、协会、班级等组织中担任主要学生干部，认真履行职责，且获得过校级及以上优秀学生干部称号；" name="6">
                    <div>积极主动为师生服务。在团委、学生会、易班、社团、协会、班级等组织中担任主要学生干部，认真履行职责，且获得过校级及以上优秀学生干部称号；</div>
                    <div>积极参与社会服务。积极做好社会服务工作，在校级及以上大型活动中发挥重要作用，受到主办单位的嘉奖或认可，服务成效显著；</div>
                    <div>学业成绩优良。学年平均学分绩在专业排名前30%。</div>
                </el-collapse-item>
                <el-collapse-item title="查看更多" name="7">
                    <div>
                        <span @click="lookMore"
                            style="text-decoration: underline;color: lightskyblue;cursor: pointer;">点我查看更多</span>
                    </div>
                </el-collapse-item>
            </el-collapse>
        </div>

        <el-drawer :modal="false" size="50%" title="申请要求" :visible.sync="lookNeedV" direction="ltr" :append-to-body="true">
            <div class="sign">
                <ul>
                    <li>
                        申请要求:综合素质优秀。学年综合测评班级排名前30%；学习成绩优良，无不及格、补考、重修科目；体能成绩合格等
                    </li>
                    <li>
                        学业之星:
                        <ol>
                            <li>学业成绩名列前茅。学年平均学分绩在专业排名前5%；获得校级及以上先进个人项目表彰；</li>
                            <li>专业领域成果突出。在与专业相关的知识竞赛、技能竞赛中获奖。优先推荐发表过专业论文者。</li>
                        </ol>
                    </li>
                    <li>
                        技能之星:
                        <ol>
                            <li>技能或创新创业比赛成绩优异。积极参加技能训练、技能比赛或创新创业类比赛，在省部级及以上举办的技能类、创新创业类比赛中获得三等奖及以上，或在市厅级举办的技能类、创新创业类比赛中获得二等奖及以上，或在校级组织的技能类、创新创业类比赛中获得一等奖及以上；
                            </li>
                            <li>专业技能成绩优良。在本专业技能考核中成绩突出，学年平均学分绩在专业排名前30%；</li>
                            <li>专业技能突出。取得与专业相关的资格、资质证书、专利（排名前五）或者在专业技能某个方面特别突出者优先考虑。</li>
                        </ol>
                    </li>
                    <li>
                        励志之星:
                        <ol>
                            <li>在评选学年中被认定为家庭经济困难学生，自立自强，热爱生活，吃苦耐劳，勇于拼搏，乐观向上，有突出的励志事迹，能够激励他人、影响他人，在同学中认可度高；
                            </li>
                            <li>在专业学习、勤工俭学、社会实践、科技创新、励志感恩、创新创业、公益服务等方面取得突出成绩；</li>
                            <li>学业成绩优良，学年平均学分绩在专业排名前30%，获得校级及以上先进个人项目表彰。</li>
                        </ol>
                    </li>

                    <li>
                        才艺之星:
                        <ol>
                            <li>才艺成绩突出。在校内外各类文体赛事中（如体育、美术、音乐、舞蹈、戏剧、摄影摄像、写作、演讲、辩论等）成绩突出。
                            </li>
                            <li>学业成绩优良。学年平均学分绩在专业排名前30%。</li>
                        </ol>
                    </li>
                    <li>
                        服务之星:
                        <ol>
                            <li>积极主动为师生服务。在团委、学生会、易班、社团、协会、班级等组织中担任主要学生干部，认真履行职责，且获得过校级及以上优秀学生干部称号；
                            </li>
                            <li>积极参与社会服务。积极做好社会服务工作，在校级及以上大型活动中发挥重要作用，受到主办单位的嘉奖或认可，服务成效显著；</li>
                            <li>学业成绩优良。学年平均学分绩在专业排名前30%。</li>
                        </ol>
                    </li>

                    <li>
                        <span @click="lookMore"
                            style="text-decoration: underline;color: lightskyblue;cursor: pointer;">查看更多</span>
                    </li>
                </ul>
            </div>
        </el-drawer>



        <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="68px">
            <el-form-item label="奖项" prop="code">
                <el-select clearable v-model="queryParams.code">
                    <el-option v-for="(v, i) in search_type_list" :key="i" clearable :value="v.typeCode"
                        :label="v.typeName"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="审核状态" prop="status">
                <el-select size="mini" v-model="queryParams.status" placeholder="审核状态" clearable>
                    <el-option v-for="(v, i) in applyStatus" :key="i" :label="v.label" :value="v.value" />
                </el-select>
            </el-form-item>
            <el-form-item label=" ">
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                <el-button type="success" icon="el-icon-view" size="mini" @click="lookNeedV = true;">查看申请要求</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-plus" size="mini" @click="addVClick">我要申请百名优秀大学生</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-plus" size="mini" @click="addTenVClick">我要申请十佳大学生</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-view" size="mini" @click="myScoreVClick()">查看我的成绩</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-view" size="mini" @click="iamVClick()">查看我的思想品德</el-button>
            </el-col>
        </el-row>


        <el-table v-loading="loading" :data="table_data">
            <el-table-column label="学号" prop="stuNo" align="center" width="120px" />
            <el-table-column label="学生" prop="stuName" align="center" width="100px" />
            <el-table-column label="奖项" prop="typeName" align="center" width="200px" />
            <el-table-column label="学年" prop="stuYearName" align="center" width="200px" />
            <el-table-column label="银行卡号" prop="bankCard" align="center" />
            <el-table-column label="开户行" prop="bankAddr" align="center" />
            <el-table-column label="申请状态" align="center" width="120px">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.audius_detail_type" :value="scope.row.applyStatus" />
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="100px">
                <template slot-scope="scope">
                    <el-button type="text" size="mini" icon="el-icon-view" @click="lookVClick(scope.row)">查看详情</el-button>
                    <el-button v-if="scope.row.applyStatus == 1" type="text" size="mini" icon="el-icon-delete"
                        @click="cancelVClick(scope.row)">取消申请</el-button>
                    <el-button v-if="scope.row.applyStatus == 10" type="text" size="mini" icon="el-icon-refresh"
                        @click="reApplyVClick(scope.row)" fixed="right">重新提交</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />



        <el-dialog :visible.sync="myScoreV" title="我的成绩" width="900px">
            <el-table :data="score_list">
                <el-table-column label="学年" prop="stuYearName" align="center" />
                <el-table-column label="平均学分绩" prop="stuScore" align="center" />
                <el-table-column label="综合素质总成绩" prop="cphScore" align="center" />
                <el-table-column label="体能测试成绩" prop="sportScore" align="center" />
                <el-table-column label="平均学分绩专业排名" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.stuMajorRank + '/' + scope.row.majorCount }}
                    </template>
                </el-table-column>
                <el-table-column label="综合素质总成绩班级排名" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.cphClassRank + '/' + scope.row.classCount }}
                    </template>
                </el-table-column>
                <el-table-column label="平均学分绩专业排名百分比" align="center">
                    <template slot-scope="scope">
                        {{ Math.round(scope.row.stuMajorRank / scope.row.majorCount * 10000) / 100 + "%" }}
                    </template>
                </el-table-column>
                <el-table-column label="学年综合素质测评班级排名百分比" align="center">
                    <template slot-scope="scope">
                        {{ Math.round(scope.row.cphClassRank / scope.row.classCount * 10000) / 100 + "%" }}
                    </template>
                </el-table-column>
            </el-table>
            <el-table :data="count_list">
                <el-table-column label="学年" prop="stuYearName" align="center" />
                <el-table-column label="课程总门数" prop="courseCount" align="center" />
                <el-table-column label="通过门数" prop="passCount" align="center" />
                <el-table-column label="未通过门数" prop="unpassCount" align="center" />
            </el-table>


            <el-table :data="course_list" v-loading="course_loading">
                <el-table-column label="学期" prop="termName" align="center" />
                <el-table-column label="课程" prop="courseName" align="center" />
                <el-table-column label="成绩" prop="courseScore" align="center" />
                <el-table-column label="是否通过" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.isPass == "true" ? "通过" : "未通过" }}
                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="courseTotal > 0" :total="courseTotal" :page.sync="courseParams.pageNum"
                :limit.sync="courseParams.pageSize" @pagination="listOwnCourseScore" />
        </el-dialog>

        <el-dialog :visible.sync="iamV" title="我的思想品德">
            <el-table :data="iam_count">
                <el-table-column label="学年" prop="stuYearName" align="center" />
                <el-table-column label="总记录数" prop="iamCount" align="center" />
                <el-table-column label="加分数" prop="addCount" align="center" />
                <el-table-column label="扣分数" prop="minusCount" align="center" />
            </el-table>
        </el-dialog>

        <el-dialog :visible.sync="lookV" title="查看详情" fullscreen>
            <el-form label-width="160px" class="apply-form">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="学年">
                            <el-input size="mini" class="addForm-input" v-model="lookForm.stuYearName" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="奖项">
                            <el-input size="mini" class="addForm-input" v-model="lookForm.typeName" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="政治面貌">
                            <el-input size="mini" class="addForm-input" v-model="lookForm.zzmm" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="职务">
                            <el-input size="mini" class="addForm-input" v-model="lookForm.classPost" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="中国农业银行银行卡号">
                            <el-input size="mini" class="addForm-input" v-model="lookForm.bankCard" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="开户行">
                            <el-input size="mini" class="addForm-input" v-model="lookForm.bankAddr" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="获奖情况">
                            <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 10 }" class="addForm-input"
                                v-model="lookForm.goodHis" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="主要事迹">
                            <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 10 }" class="addForm-input"
                                v-model="lookForm.mainHis" readonly></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="辅导员审核意见" v-if="!isEmpty(lookForm.fdyComment)">
                            <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 10 }" class="addForm-input"
                                v-model="lookForm.fdyComment" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="学院审核意见" v-if="!isEmpty(lookForm.xwComment)">
                            <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 10 }" class="addForm-input"
                                v-model="lookForm.xwComment" readonly></el-input>
                        </el-form-item>
                        <el-form-item label="学工审核意见" v-if="!isEmpty(lookForm.jwcComment)">
                            <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 10 }" class="addForm-input"
                                v-model="lookForm.jwcComment" readonly></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-dialog>


        <el-dialog :visible.sync="addV" title="我要申请百名优秀大学生">
            <el-form label-width="160px" class="apply-form">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="学年">
                            <el-select v-model="addForm.stuYearId" size="mini" class="addForm-input">
                                <el-option v-for="(v, i) in year_list" :key="i" :label="v.stuYearName"
                                    :value="v.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="奖项">
                            <el-select @change="changeType" v-model="addForm.typeCode" size="mini" class="addForm-input">
                                <el-option v-for="(v, i) in apply_type_list" :key="i" :label="v.typeName"
                                    :value="v.typeCode"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="政治面貌">
                            <el-input size="mini" class="addForm-input" v-model="addForm.zzmm"
                                placeholder="请输入政治面貌(例如：群众、共青团员)"></el-input>
                        </el-form-item>
                        <el-form-item label="职务">
                            <el-input size="mini" class="addForm-input" v-model="addForm.classPost"
                                placeholder="请输入职务(例如：班长，没有填 无)"></el-input>
                        </el-form-item>
                        <el-form-item label="中国农业银行银行卡号">
                            <el-input size="mini" class="addForm-input" v-model="addForm.bankCard"
                                placeholder="请输入中国农业银行银行卡号"></el-input>
                        </el-form-item>
                        <el-form-item label="开户行">
                            <el-input size="mini" class="addForm-input" v-model="addForm.bankAddr"
                                placeholder="例如：中国农业银行南宁望州支行"></el-input>
                        </el-form-item>
                        <el-form-item label="获奖情况">
                            <el-input type="textarea" :maxlength="1000" :autosize="{ minRows: 10, maxRows: 10 }"
                                class="addForm-input" v-model="addForm.goodHis" placeholder="请输入获奖情况"></el-input>
                        </el-form-item>
                        <el-form-item label="主要事迹">
                            <el-input type="textarea" :maxlength="1000" :autosize="{ minRows: 10, maxRows: 10 }"
                                class="addForm-input" v-model="addForm.mainHis" placeholder="请输入主要事迹，字数100字以上"></el-input>
                        </el-form-item>
                        <el-form-item label="">
                            <el-button type="primary" size="mini" @click="doApply">提交申请</el-button>
                        </el-form-item>
                    </el-col>

                </el-row>

            </el-form>
        </el-dialog>

        <el-dialog :visible.sync="addTenV" title="我要申请十佳大学生">
            <el-form label-width="160px" class="apply-form">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="学年">
                            <el-select v-model="addTenForm.stuYearId" size="mini" class="addForm-input">
                                <el-option v-for="(v, i) in year_list" :key="i" :label="v.stuYearName"
                                    :value="v.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="政治面貌">
                            <el-input size="mini" class="addForm-input" v-model="addTenForm.zzmm"
                                placeholder="请输入政治面貌(例如：群众、共青团员)"></el-input>
                        </el-form-item>
                        <el-form-item label="职务">
                            <el-input size="mini" class="addForm-input" v-model="addTenForm.classPost"
                                placeholder="请输入职务(例如：班长，没有填 无)"></el-input>
                        </el-form-item>
                        <el-form-item label="中国农业银行银行卡号">
                            <el-input size="mini" class="addForm-input" v-model="addTenForm.bankCard"
                                placeholder="请输入中国农业银行银行卡号"></el-input>
                        </el-form-item>
                        <el-form-item label="开户行">
                            <el-input size="mini" class="addForm-input" v-model="addTenForm.bankAddr"
                                placeholder="例如：中国农业银行南宁望州支行"></el-input>
                        </el-form-item>
                        <el-form-item label="获奖情况">
                            <el-input type="textarea" :maxlength="1000" :autosize="{ minRows: 10, maxRows: 10 }"
                                class="addForm-input" v-model="addTenForm.goodHis" placeholder="请输入获奖情况"></el-input>
                        </el-form-item>
                        <el-form-item label="主要事迹">
                            <el-input type="textarea" :maxlength="1000" :autosize="{ minRows: 10, maxRows: 10 }"
                                class="addForm-input" v-model="addTenForm.mainHis"
                                placeholder="请输入主要事迹，字数100字以上"></el-input>
                        </el-form-item>
                        <el-form-item label="">
                            <el-button type="primary" size="mini" @click="doApplyTen">提交申请</el-button>
                        </el-form-item>
                    </el-col>

                </el-row>

            </el-form>
        </el-dialog>


        <el-dialog :visible.sync="reApplyV" title="重新申请百名优秀大学生">
            <el-form label-width="160px" class="apply-form">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="学年">
                            <el-select v-model="reApplyForm.stuYearId" size="mini" class="addForm-input">
                                <el-option v-for="(v, i) in year_list" :key="i" :label="v.stuYearName"
                                    :value="v.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item v-if="reApplyForm.typeCode != null && reApplyForm.typeCode.search('SJDXS') == -1"
                            label="奖项">
                            <el-select @change="changeType" v-model="reApplyForm.typeCode" size="mini"
                                class="addForm-input">
                                <el-option v-for="(v, i) in apply_type_list" :key="i" :label="v.typeName"
                                    :value="v.typeCode"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="政治面貌">
                            <el-input size="mini" class="addForm-input" v-model="reApplyForm.zzmm"
                                placeholder="请输入政治面貌(例如：群众、共青团员)"></el-input>
                        </el-form-item>
                        <el-form-item label="职务">
                            <el-input size="mini" class="addForm-input" v-model="reApplyForm.classPost"
                                placeholder="请输入职务(例如：班长，没有填 无)"></el-input>
                        </el-form-item>
                        <el-form-item label="中国农业银行银行卡号">
                            <el-input size="mini" class="addForm-input" v-model="reApplyForm.bankCard"
                                placeholder="请输入中国农业银行银行卡号"></el-input>
                        </el-form-item>
                        <el-form-item label="开户行">
                            <el-input size="mini" class="addForm-input" v-model="reApplyForm.bankAddr"
                                placeholder="例如：中国农业银行南宁望州支行"></el-input>
                        </el-form-item>
                        <el-form-item label="获奖情况">
                            <el-input type="textarea" :maxlength="1000" :autosize="{ minRows: 10, maxRows: 10 }"
                                class="addForm-input" v-model="reApplyForm.goodHis" placeholder="请输入获奖情况"></el-input>
                        </el-form-item>
                        <el-form-item label="主要事迹">
                            <el-input type="textarea" :maxlength="1000" :autosize="{ minRows: 10, maxRows: 10 }"
                                class="addForm-input" v-model="reApplyForm.mainHis"
                                placeholder="请输入主要事迹，字数100字以上"></el-input>
                        </el-form-item>
                        <el-form-item label="">
                            <el-button type="primary" size="mini" @click="reApply">提交申请</el-button>
                        </el-form-item>
                    </el-col>

                </el-row>

            </el-form>
        </el-dialog>


        <el-dialog :visible.sync="lookMoreV" :append-to-body="true">
            <MoreDetail></MoreDetail>
        </el-dialog>

    </div>
</template>
<script>
import { listOneHundred, listSelect } from "@/api/stuCQS/lake/type";

import { listOwnApply, cancelOwnApply, applyLake, applyTen, reApplyLake } from "@/api/stuCQS/lake/apply";

import {
    getOwnPassCountByCode, getOwnIamCountByCode, getOwnRankByCode,
    listXyjxjCanType, countOwnPass, listOwnScoreClassRank,
    listOwnYearCourseScore, countOwnIam
} from "@/api/stuCQS/good/apply";
import { listEnableYear as listYear } from "@/api/stuCQS/basedata/year";

import {
    applyStatus
} from "@/api/stuCQS/good/audit";
import { isEmpty } from "@/api/helpFunc";
import { alipayVali } from "@/api/helpFunc/bank";

import lodash from "lodash";
import MoreDetail from '@/views/stuCQS/lake/MoreDetail.vue';

export default {
    name: "iwantapply",
    dicts: ['audius_detail_type'],
    components: {
        MoreDetail
    },
    data() {
        return {
            activeNames: [],
            applyStatus,
            isEmpty,
            fullLoading: false,

            lookNeedV: false,

            search_type_list: [],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                code: null,
                status: null
            },
            loading: false,
            table_data: [],
            total: 0,


            addV: false,
            apply_type_list: [],
            addForm: {
                typeCode: null,
                zzmm: "",
                classPost: "",
                bankCard: "",
                bankAddr: "",
                goodHis: "",
                mainHis: "",
                stuYearId: null
            },

            score_list: [],
            myScoreV: false,
            course_list: [],
            courseParams: {
                pageNum: 1,
                pageSize: 10
            },
            courseTotal: 0,
            course_loading: false,

            count_list: [],

            iamV: false,
            iam_count: [],
            lookV: false,
            lookForm: {},

            can_list: [],
            year_list: [],

            lookMoreV: false,

            addTenV: false,
            addTenForm: {
                zzmm: "",
                classPost: "",
                bankCard: "",
                bankAddr: "",
                goodHis: "",
                mainHis: "",
                stuYearId: null
            },

            reApplyV: false,
            reApplyForm: {
                typeCode: null,
                zzmm: "",
                classPost: "",
                bankCard: "",
                bankAddr: "",
                goodHis: "",
                mainHis: "",
                stuYearId: null,
                id: null
            }
        }
    },
    created() {
        this.listStuYear();
        this.listCan();
        this.listSelect();
        this.listOneHundred();

        this.getList();
    },
    methods: {
        async reApply() {
            let sdata = { ...this.reApplyForm };

            if (isEmpty(sdata.stuYearId)) {
                this.$message.info("请选择学年");
                return;
            }

            if (isEmpty(sdata.typeCode)) {
                this.$message.info("请选择奖项");
                return;
            }
            if (isEmpty(sdata.zzmm)) {
                this.$message.info("请填写政治面貌");
                return;
            }
            if (isEmpty(sdata.classPost)) {
                this.$message.info("请填写职务");
                return;
            }
            if (isEmpty(sdata.bankCard)) {
                this.$message.info("请填写中国农业银行银行卡号");
                return;
            }
            if (isEmpty(sdata.bankAddr)) {
                this.$message.info("请填写开户行");
                return;
            }
            if (isEmpty(sdata.goodHis)) {
                this.$message.info("请填写获奖记录");
                return;
            }
            if (isEmpty(sdata.mainHis)) {
                this.$message.info("请填写主要事迹");
                return;
            }
            if (sdata.mainHis.length < 100) {
                this.$message.info("主要事迹字数需要100字以上");
                return;
            }

            let card = sdata.bankCard;
            let boolCard = await alipayVali(card);
            if (boolCard.validated == false) {
                this.$message.info("请输入正确的银行卡号");
                return;
            }

            if (boolCard.bank != "ABC") {
                this.$message.info("请输入正确的中国农业银行银行卡号");
                return;
            }

            this.fullLoading = true;
            let res = await reApplyLake(sdata);
            this.fullLoading = false;
            if (res.code == 200) {
                this.reApplyV = false;
                this.$message.success(res.msg);
                this.getList();
            }
        },
        reApplyVClick(v) {
            this.reApplyForm = { ...v };
            this.reApplyV = true;
        },
        async doApplyTen() {
            let sdata = { ...this.addTenForm };

            if (isEmpty(sdata.stuYearId)) {
                this.$message.info("请选择学年");
                return;
            }
            if (isEmpty(sdata.zzmm)) {
                this.$message.info("请填写政治面貌");
                return;
            }
            if (isEmpty(sdata.classPost)) {
                this.$message.info("请填写职务");
                return;
            }
            if (isEmpty(sdata.bankCard)) {
                this.$message.info("请填写中国农业银行银行卡号");
                return;
            }
            if (isEmpty(sdata.bankAddr)) {
                this.$message.info("请填写开户行");
                return;
            }
            if (isEmpty(sdata.goodHis)) {
                this.$message.info("请填写获奖记录");
                return;
            }
            if (isEmpty(sdata.mainHis)) {
                this.$message.info("请填写主要事迹");
                return;
            }
            if (sdata.mainHis.length < 100) {
                this.$message.info("主要事迹字数需要100字以上");
                return;
            }

            let card = sdata.bankCard;
            let boolCard = await alipayVali(card);
            if (boolCard.validated == false) {
                this.$message.info("请输入正确的银行卡号");
                return;
            }

            if (boolCard.bank != "ABC") {
                this.$message.info("请输入正确的中国农业银行银行卡号");
                return;
            }

            this.fullLoading = true;
            let res = await applyTen(sdata);
            this.fullLoading = false;
            if (res.code == 200) {
                this.addTenV = false;
                this.$message.success(res.msg);
                this.getList();
            }
        },
        async addTenVClick() {
            this.addTenV = true;
        },
        async changeType(v) {
            let need = "XYZX";
            if (!isEmpty(v)) {
                if (v.search(need) != -1) {
                    let cans = [...this.can_list];
                    if (cans.length == 0) {
                        return;
                    }
                    let code = cans[0].typeCode;
                    let res3 = await getOwnRankByCode(code);
                    if (res3.code == 200) {
                        if (!isEmpty(res3.data)) {
                            let rankData = res3.data;
                            let majorCount = rankData.majorCount;
                            let stuMajorRank = rankData.stuMajorRank;
                            let stuPer = Math.round(stuMajorRank / majorCount * 10000) / 100;
                            if (stuPer > 10) {
                                this.$message.info("您的平均学分绩专业排名不符合要求，不能申请学业之星。");
                                this.addForm.typeCode = null;
                                return;
                            }
                        }
                    }
                }
            }
        },
        lookMore() {
            this.lookMoreV = true;
            window.open('http://zhxg.gxsdxy.cn/file/jhzx2023.pdf');
        },
        async listStuYear() {
            let res = await listYear();
            if (res.code == 200) {
                this.year_list = [...res.rows];
            }
        },

        async doApply() {
            let sdata = { ...this.addForm };

            if (isEmpty(sdata.stuYearId)) {
                this.$message.info("请选择学年");
                return;
            }

            if (isEmpty(sdata.typeCode)) {
                this.$message.info("请选择奖项");
                return;
            }
            if (isEmpty(sdata.zzmm)) {
                this.$message.info("请填写政治面貌");
                return;
            }
            if (isEmpty(sdata.classPost)) {
                this.$message.info("请填写职务");
                return;
            }
            if (isEmpty(sdata.bankCard)) {
                this.$message.info("请填写中国农业银行银行卡号");
                return;
            }
            if (isEmpty(sdata.bankAddr)) {
                this.$message.info("请填写开户行");
                return;
            }
            if (isEmpty(sdata.goodHis)) {
                this.$message.info("请填写获奖记录");
                return;
            }
            if (isEmpty(sdata.mainHis)) {
                this.$message.info("请填写主要事迹");
                return;
            }
            if (sdata.mainHis.length < 100) {
                this.$message.info("主要事迹字数需要100字以上");
                return;
            }

            let card = sdata.bankCard;
            let boolCard = await alipayVali(card);
            if (boolCard.validated == false) {
                this.$message.info("请输入正确的银行卡号");
                return;
            }

            if (boolCard.bank != "ABC") {
                this.$message.info("请输入正确的中国农业银行银行卡号");
                return;
            }

            this.fullLoading = true;
            let res = await applyLake(sdata);
            this.fullLoading = false;
            if (res.code == 200) {
                this.addV = false;
                this.resetAddForm();
                this.$message.success(res.msg);
                this.getList();
            }
        },
        resetAddForm() {
            this.addForm = {
                typeCode: null,
                zzmm: "",
                classPost: "",
                bankCard: "",
                bankAddr: "",
                goodHis: "",
                mainHis: "",
                stuYearId: null
            }
        },
        async addVClick() {
            this.fullLoading = true;
            let cans = [...this.can_list];
            if (cans.length == 0) {
                this.fullLoading = false;
                return;
            }
            let code = cans[0].typeCode;
            let res1 = await getOwnPassCountByCode(code);
            if (res1.code == 200) {
                let data1 = res1.data;
                if (isEmpty(data1)) {
                    data1 = {
                        unpassCount: 0
                    }
                }
                if (data1.unpassCount != 0) {
                    this.$message.info("您有课程成绩没通过，不能申请哦");
                    this.fullLoading = false;
                    return;
                }
            }

            let res2 = await getOwnIamCountByCode(code);
            if (res2.code == 200) {
                let data2 = res2.data;
                if (isEmpty(data2)) {
                    data2 = {
                        minusCount: 0
                    }
                }
                if (data2.minusCount != 0) {
                    this.$message.info("您有思想品德扣分项，不能申请哦");
                    this.fullLoading = false;
                    return;
                }
            }

            let res3 = await getOwnRankByCode(code);
            if (res3.code == 200) {
                if (!isEmpty(res3.data)) {
                    let rankData = res3.data;
                    let classCount = rankData.classCount;
                    let cphClassRank = rankData.cphClassRank;
                    let majorCount = rankData.majorCount;
                    let stuMajorRank = rankData.stuMajorRank;

                    let cphPer = Math.round(cphClassRank / classCount * 10000) / 100;
                    let stuPer = Math.round(stuMajorRank / majorCount * 10000) / 100;

                    if (cphPer > 35) {
                        this.$message.info("您的综合素质成绩排名不达标");
                        this.fullLoading = false;
                        return;
                    }

                    if (stuPer > 35) {
                        this.$message.info("您的平均学分绩排名不达标");
                        this.fullLoading = false;
                        return;
                    }

                    let sportScore = rankData.sportScore;
                    if (sportScore < 60) {
                        this.$message.info("您的体能成绩不达标");
                        this.fullLoading = false;
                        return;
                    }
                }
            }

            this.fullLoading = false;
            this.addV = true;
        },

        async listCan() {
            let res = await listXyjxjCanType();
            if (res.code == 200) {
                this.can_list = lodash.cloneDeep(res.data);
            }
        },
        lookVClick(val) {
            this.lookForm = lodash.cloneDeep(val);
            this.lookV = true;
        },
        cancelVClick(val) {
            if (val != null) {
                let id = val.id;
                if (!isEmpty(id)) {
                    this.$prompt('清输入取消理由', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        inputPattern:/^.+$/,
                        inputErrorMessage: '不能为空'
                    }).then(async ({ value }) => {
                        let sdata = {
                            id: id,
                            reason: value
                        };
                        this.fullLoading = true;
                        let res = await cancelOwnApply(sdata);
                        this.fullLoading = false;
                        if (res.code == 200) {
                            this.$message.success(res.msg);
                            this.getList();
                        }

                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '取消输入'
                        });
                    });
                }
            }
        },
        async listSelect() {
            let res = await listSelect();
            if (res.code == 200) {
                this.search_type_list = [...res.data];
            }
        },
        async listOneHundred() {
            let res = await listOneHundred();
            if (res.code == 200) {
                this.apply_type_list = [...res.data];
            }
        },
        async getList() {
            let res = await listOwnApply();
            if (res.code == 200) {
                this.total = res.total;
                this.table_data = [...res.rows];
            }
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        iamVClick() {
            this.countOwnIam();
            this.iamV = true;
        },
        async countOwnIam() {
            let res = await countOwnIam();
            if (res.code == 200) {
                this.iam_count = res.data;
            }
        },
        async listOwnCourseScore() {
            this.course_loading = true;
            let res = await listOwnYearCourseScore(this.courseParams);
            this.course_loading = false;

            if (res.code == 200) {
                this.course_list = [...res.rows];
                this.courseTotal = res.total;
            }
        },
        async listOwnScoreClassRank() {
            let res = await listOwnScoreClassRank();
            if (res.code == 200) {
                this.score_list = lodash.cloneDeep(res.data);
            }
        },
        async countOwnPass() {
            let res = await countOwnPass();
            if (res.code == 200) {
                this.count_list = [...res.data];
            }
        },

        myScoreVClick() {
            this.countOwnPass();
            this.listOwnScoreClassRank();
            this.listOwnCourseScore();
            this.myScoreV = true;
        },
    }
}


</script>
<style lang="scss" scoped>

.addForm-input {
    width: 400px;
}

.apply-form {
    .el-form-item {
        margin-bottom: 0px;
    }

}

.sign {
    width: 100%;
    border: 1px solid rgb(163, 211, 255);
    font-size: small;
    margin-bottom: 10px;
    border-radius: 2px;
}
</style>